package utils
{
	import flash.display.Sprite;
	import flash.display.LineScaleMode;
	import flash.display.CapsStyle;
	import flash.display.JointStyle;
	public class Line extends Sprite
	{
		static public var sets:Array = [];
		public var _alpha:Number = 0.5;
		public var sX:int;
		public var sY:int;
		public var eX:int;
		public var eY:int;
		public var linesize:Number;
		public var color:Number;
		public function Line($sX:int, $sY:int, $eX:int, $eY:int,_co:Number,$linesize:Number = 8)
		{
			sets.push(this);
			sX = $sX;
			sY = $sY;
			eX = $eX;
			eY = $eY;
			color = _co;
			linesize = $linesize;
			draw();
		}
		private function draw():void
		{
			graphics.clear();
			graphics.lineStyle(linesize, color,_alpha,false,LineScaleMode.NONE,CapsStyle.ROUND,JointStyle.ROUND,0);
			graphics.moveTo(sX, sY);
			graphics.lineTo(eX, eY);
		}
		public function update():void
		{
			draw();
			linesize -=  1;
			
			if (linesize < 1)
			{
				clear();
			}
		}
		private function clear():void
		{
			graphics.clear();
			for (var i:String in sets)
			{
				var l:Line = sets[i] as Line;
				if (l == this)
				{
					sets.splice(i, 1);
					parent.removeChild(this);
				}
			}
		}
	}
}